import { Ctype } from "../../ServerProxy/Ctype";
import { decodeUnameLoginReq, encodeUnameLoginReq } from "../../ServerProxy/Proto/game_pb";

export class ProtoMag {
    public static Instance: ProtoMag = new ProtoMag();

    //序列化数据
    public SerializeMsg(ctype: Ctype, data: any) {
        let buff: Uint8Array = null;
        switch (ctype) {
            case Ctype.UnameLoginReq:
                buff = encodeUnameLoginReq(data);
                break;
            //... ... ...
        }

        return buff;
    }

    //反序列化数据
    public DeserializeMsg(ctype: Ctype, buff: Uint8Array) {
        let data: any = null;
        switch (ctype) {
            case Ctype.UnameLoginReq:
                data = decodeUnameLoginReq(buff);
                break;
            //... ... ...
        }

        return data;
    }
}